<template>
  <CommonPage :type="pageType" />
</template>

<script lang="ts">
import Vue from 'vue';
import { Component, Watch } from 'vue-property-decorator';
import CommonPage from '@/components/component-common-page';

@Component({
  components: {
    CommonPage,
  },
})
/** 公共页面 */
export default class ViewCommonPage extends Vue {
  pageType: string = '404'; // 无权限

  /** 钩子幻术 */
  private mounted() {
    this.setPageType(this.$route.path);
  }

  /** 监听路由变化 */
  @Watch('$route', { deep: true })
  public routechange(to: any, from: any): any {
    this.setPageType(to.path);
  }

  /** 设置页面信息 */
  public setPageType(type: string) {
    switch (type) {
      case '/error':
        this.pageType = '404';
        break;
      case '/noPermission':
        this.pageType = 'permission';
        break;
      default:
        this.pageType = '404';
        break;
    }
  }
}
</script>
